﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Text;

namespace ASmile.ORM.ADO
{
    /// <summary>
    /// 仅.net 4.0 windows可用
    /// </summary>
    public class OleDbHelper : IDBHelper
    {
        public OleDbHelper(string connStr)
            : base(connStr)
        { }

        OleDbConnection _DBConnectionObj;
        OleDbCommand _DbCommandObj;
        OleDbDataAdapter _DbDataAdapterObj;

        public override string ParamSign => Config.OleDb.ParamSign;

        public override DbConnection DBConnectionObj
        {
            get
            {
                if (_DBConnectionObj == null)
                {
                    _DBConnectionObj = new OleDbConnection(ConnStr);
                }
                return _DBConnectionObj;
            }
        }

        public override DbCommand DbCommandObj
        {
            get
            {
                if (_DbCommandObj == null)
                {
                    _DbCommandObj = new OleDbCommand();
                }
                return _DbCommandObj;
            }
        }

        protected internal override DbDataAdapter DbDataAdapterObj
        {
            get
            {
                if (_DbDataAdapterObj == null)
                {
                    _DbDataAdapterObj = new OleDbDataAdapter();
                }
                return _DbDataAdapterObj;
            }
        }

        public override DbParameter CreateDbParameter(string paramName, object paramValue)
        {
            return new OleDbParameter(paramName, paramValue);
        }

        public override int BulkInsert(DataTable data)
        {
            throw new NotImplementedException();
        }
    }
}
